var cloud_1 = []
Object.keys(data).forEach(state => {
    cloud_1.push({
        "name": state,
        "value": data[state]['2020/05/19']['cumsum_confirmed'],
    })

})

// 取前十个最小的
var top_less_10 = cloud_1.sort(function(a, b) {
    return a.value - b.value
}).slice(0, 10)

// for (var idx = 0; idx < 10; idx++) {
//     min_10[idx] = min_10[idx] / min_10[-1]
// }

console.log('top_less_10', top_less_10)


var cloud_1_data = {
    value: top_less_10,

    image: ''
}
var maskImage = new Image();
maskImage.src = cloud_1_data.image


var word_cloud_1_option = {
    title: {
        text: 'Top 10 States with Least Cases',
        left: '10%'
    },
    //backgroundColor: '#fff',
    tooltip: {
        show: true
    },
    series: [{
        type: 'wordCloud',
        gridSize: 1,
        sizeRange: [12, 55],
        rotationRange: [-45, 0, 45, 90],
        maskImage: maskImage,
        textStyle: {
            normal: {
                color: function() {
                    return 'rgb(' +
                        Math.round(Math.random() * 255) +
                        ', ' + Math.round(Math.random() * 255) +
                        ', ' + Math.round(Math.random() * 255) + ')'
                }
            }
        },
        left: '10%',
        top: 'center',
        width: '100%',
        height: '100%',
        right: null,
        bottom: null,
        // width: 300,
        // height: 200,
        // top: 20,
        data: cloud_1_data.value
    }]


}


$(function() {

    var word_cloud_1 = echarts.init(document.getElementById('word_cloud_1'))
    word_cloud_1.setOption(word_cloud_1_option)
})